home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_Clock / ClockApp.m < prev    next >
Encoding:
Text File  |  1992-12-19  |  3.0 KB  |  125 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34. *    ClockApp.m
  35. *
  36. *    This class creates the window that the clock goes in and then
  37. *    installs a ClockView object as the content view. The clock is 
  38. *    initialized by drawing the clock face, sending the user paths for
  39. *    the hands down to the server and defining the gstates.
  40.  *
  41.  *    Version:    2.0
  42.  *    Author:    Ken Fromm
  43.  *    History:
  44.  *            03-07-91        Added this comment.
  45. */
  46.  
  47. #import "ClockApp.h"
  48. #import "ClockView.h"
  49. #import <appkit/Application.h>
  50. #import <appkit/Control.h>
  51. #import <appkit/Window.h>
  52.  
  53. @implementation ClockApp
  54.  
  55. /*
  56. *  Create a window, install a ClockView object as the content view and
  57. *  initialize the clock.
  58. */
  59. + new
  60. {
  61.     NXRect    aRect;
  62.     
  63.     self = [super new]; 
  64.  
  65.     NXSetRect(&aRect, 250.0, 400.0, 400.0, 375.0); 
  66.     windowId = [Window newContent:&aRect
  67.                 style:NX_TITLEDSTYLE 
  68.                 backing:NX_BUFFERED 
  69.                 buttonMask:NX_RESIZEBUTTONMASK
  70.                 defer:NO]; 
  71.     [windowId setTitle:"Clock"];
  72.  
  73.     viewId = [ClockView new];
  74.     [[windowId setContentView:viewId] free];
  75.  
  76.     [viewId  drawFace];
  77.     [viewId  defineUPaths];
  78.     [viewId  defineGStates];
  79.  
  80.     [windowId display];
  81.     [windowId makeKeyAndOrderFront:self];
  82.  
  83.     return self;
  84. }
  85.  
  86. /* The view is freed when the window is freed. */
  87. - free
  88. {
  89.     [windowId  free];
  90.  
  91.     return [super  free];
  92. }
  93.  
  94. /* Set the target and actions for the buttons. */
  95. - setGstateButton:anObject
  96. {
  97.     [[anObject   setTarget:viewId] setAction:@selector(toggleGstate:)];
  98.  
  99.     return self;
  100. }
  101.  
  102. - setUpathButton:anObject
  103. {
  104.     [[anObject   setTarget:viewId] setAction:@selector(toggleUpath:)];
  105.  
  106.     return self;
  107. }
  108.  
  109. - setTraceItem:anObject
  110. {
  111.     [[anObject   setTarget:viewId] setAction:@selector(trace:)];
  112.  
  113.     return self;
  114. }
  115.  
  116. /* Pass the id for the time display field to the ClockView object. */
  117. - setDisplayTime:anObject
  118. {
  119.     [viewId setDisplayTime:anObject];
  120.  
  121.     return self;
  122. }
  123.  
  124. @end
  125.